<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>天气查询</title>
    <script src="../js/vue.js"></script>
    <script src="../js/axios.js"></script>
</head>
<body>
<div id="app">
    <input type="text" v-model="city">
    <button @click="get_weather">点击获取天气</button>
    <div id="show" :style="boxx">
        <div>查询城市：{{city}}</div>
        <div>近五天的天气情况 :
            <div style="color:#ffa315">温馨提示 :{{ganmao}}</div>

            <table border="1" width="600px">
                <tr>
                    <th>时间</th>
                    <th>最高温度</th>
                    <th>最低温度</th>
                    <th>风力</th>
                    <th>风向</th>
                    <th>天气</th>
                </tr>
                <tr v-for="wh in weather">
                    <td>{{wh.date}}</td>
                    <td>{{wh.high}}</td>
                    <td>{{wh.low}}</td>
                    <td>{{wh.fengli}}</td>
                    <td>{{wh.fengxiang}}</td>
                    <td>{{wh.type}}</td>
                </tr>
            </table>


        </div>
    </div>
</div>
<script>
    let vm = new Vue({
        el: "#app",
        data: {
            city: "",
            weather: "",
            ganmao: "",
            type: "",
            boxx: {
                display: 'none',
            },
        },
        methods: {
            get_weather() {
                this.boxx = {};
                axios.get("http://wthrcdn.etouch.cn/weather_mini?city=" + this.city)
                    .then(response => {
                        this.city = response.data['data']['city'];
                        this.weather = response.data['data'].forecast;
                        this.ganmao = response.data['data'].ganmao;
                        this.type = response.data['type'].ganmao;
                        console.log(response);

                    }).catch(error => {
                    console.log(error.response)
                });

            }
        }
    })
</script>
</body>
</html>